import json


class Student:
    def __init__(self, name='', age=0, score=0):
        self.name = name
        self.age = age
        self.score = score


def main():
    d = {"name": "hankskfc", "age": 11}
    ret = json.dumps(d)
    print ret

    json_str = '{"age": 20, "score": 88, "name": "Bob"}'
    obj = json.loads(json_str)
    print obj

    student = Student("hankskfc", 12, 22)
    str = json.dumps(student, default=lambda o: o.__dict__)
    print str
    s = Student()
    s.__dict__ = json.loads(str)
    print s


print

if __name__ == '__main__':
    main()
